Repository navigation
Quote a list for cmd.exe under a drive-relative path too - #113
Merged
Merged
Conversation
Batch-file quoting was picked by a pattern that needed a slash or the start of the path before 'cmd', so C:cmd.exe and C:cmd got the ordinary quoting, where a quote is written \" and cmd.exe doesn't honor it: an element like 'a" & echo X & "' ran a second command. The pattern now accepts a colon there too. Harness section AE runs the injection payload through C:cmd.exe, C:cmd and C:CMD.EXE. from System32.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong: given a list in
-Arguments, the kit picks the quotingcmd.exeneeds (a quote written"") when the program iscmd.exeor a.bat/.cmd. It recognizedcmd.exewith a pattern that needed a slash or the start of the path beforecmd, so a drive-relative path (C:cmd.exe,C:cmd) got the ordinary quoting, where a quote is written\".cmd.exedoesn't honor\", so an element likea" & echo INJECTED & "made it run a second command. The program run iscmd.exeeither way: the start resolves the drive-relative path.What changed: the pattern in
Resolve-PkArgumentListalso accepts a colon beforecmd((^|[\\/:])cmd(\.exe)?$). A.bator.cmdwas already recognized by its extension under any path.How it was tested: harness section AE runs an injection payload through
C:cmd.exe,C:cmdandC:CMD.EXE.with System32 as that drive's current folder, and checks that no second command ran and each run exited 0.[FAIL] nor under a drive-relative path to cmd.exe (3 of 3 did, 0 failed to run, 0 ran)[PASS] nor under a drive-relative path to cmd.exe (0 of 3 did, 0 failed to run, 3 ran)Full harness: all 749 assertions pass on Windows PowerShell 5.1 and on PowerShell 7.